<?php
if (post_password_required())
    return;
if (isset($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
    die ('请不要直接加载这个页面，谢谢！');
?>
<?php if (comments_open()) { ?>
<div id="comments" class="comments">
  <div class="title">
    <h2><i class="icon icon-fenlei"></i> 发表评论<span>(<?php echo get_post(get_the_ID()) -> comment_count ?>)</span></h2>
  </div>
  <div id="respond" class="respond">
    <?php if ( get_option('comment_registration') && !is_user_logged_in() ) { ?>
    <div class="respond_login">
      <h3>评论前必须登录</h3>
      <a class="login" href="<?php echo login_url('qq'); ?>">QQ快捷登录</a>
    </div>
    <?php }else{ ?>
    <form id="respond_form" action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post">
      <textarea id="respond_text" class="respond_text" name="respond_text" tabindex="1"></textarea>
      <?php if ($user_ID) : ?>
      <div class="respond_user">
        <?php echo get_avatar(get_the_author_email(), '16'); ?> 昵称：<a><?php echo $user_identity; ?></a> <a href="<?php echo wp_logout_url(get_permalink()); ?>"><?php print '退出'; ?></a>
      </div>
      <?php elseif ($comment_author != ''): ?>
      <div class="respond_author">
        <?php echo get_avatar($comment_author_email, $size = '16'); ?> <?php printf('昵称：<strong>%s</strong> ', $comment_author); ?><a
                            href="javascript:respond_toggle();" id="respond_toggle" tabindex="2">修改信息</a> 
        <script type="text/javascript" charset="utf-8">
                            $(document).ready(function () {
                                $('.respond_info').hide();
                            });
                        </script>
      </div>
      <?php endif; ?>
      <div class="respond_submit">
        <?php cancel_comment_reply_link('取消回复'); ?>
        <input id="respond_submit" type="submit" tabindex="5" value="写好了"/>
        <?php comment_id_fields(); ?>
      </div>
      <?php if (!$user_ID): ?>
      <div class="respond_info">
        <input type="text" name="author" id="author" value="<?php echo $comment_author; ?>"
                               tabindex="3"/>
        <label>昵称（必填）</label>
        <input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>"
                               tabindex="4"/>
        <label>邮箱（必填）</label>
      </div>
      <?php endif; ?>
    </form>
    <?php } ?>
  </div>
  <?php if (!have_comments()) { ?>
  <div id="respond" class="respond">
    <span class="comment"><a href="#comments">还没有任何评论，你来说两句吧</a></span>
  </div>
  <?php } else { ?>
  <ol class="comment_list">
    <?php wp_list_comments('type=comment&reverse_top_level=true&callback=mytheme_comment'); ?>
  </ol>
  <?php if (get_comment_pages_count() > 1 && get_option('page_comments')) { ?>
  <div class="navigation">
    <div class="nav-links">
      <?php paginate_comments_links('prev_text=上一页&next_text=下一页'); ?>
    </div>
  </div>
  <?php } ?>
  <?php } ?>
</div>
<?php } ?>
